package org.alex.farouq.exam.model.question;

import java.util.ArrayList;


import org.alex.farouq.exam.model.question.choice.CorrectChoice;
import org.alex.farouq.exam.model.question.choice.WrongChoice;
import org.alex.farouq.exam.model.question.mark.Mark;
import org.alex.farouq.exam.model.question.type.SubQuestionType;

/**
 * 
 * @author Ahmed abdl wahab
 * @email ahmed.mail.eg@gmail.com
 * @since 7-Nov-2011
 */
public class SubQuestion {
	
	private SubQuestionText text;
	private SubQuestionType type;
	private Mark mark;
	private ArrayList<CorrectChoice> correctChoices;
	private ArrayList<WrongChoice> wrongChoices;
	
	public SubQuestionText getText() {
		return text;
	}

	public void setText(SubQuestionText text) {
		this.text = text;
	}

	public SubQuestionType getType() {
		return type;
	}

	public void setType(SubQuestionType type) {
		this.type = type;
	}

	public Mark getMark() {
		return mark;
	}

	public void setMark(Mark mark) {
		this.mark = mark;
	}

	public ArrayList<CorrectChoice> getCorrectChoices() {
		return correctChoices;
	}

	public void setCorrectChoices(ArrayList<CorrectChoice> correctChoices) {
		this.correctChoices = correctChoices;
	}

	public ArrayList<WrongChoice> getWrongChoices() {
		return wrongChoices;
	}

	public void setWrongChoices(ArrayList<WrongChoice> wrongChoices) {
		this.wrongChoices = wrongChoices;
	}

	public String toString(){
		if((null==getText())||
			(null==getType())||
			(null==getMark())||
			(null==getCorrectChoices())||
			(null==getWrongChoices()))
				return null;
		StringBuilder correctChoiceXML = new StringBuilder();
		for(CorrectChoice correctChoice: getCorrectChoices()) correctChoiceXML.append(correctChoice);
		StringBuilder wrongChoiceXML = new StringBuilder();
		for(WrongChoice wrongChoice: getWrongChoices()) wrongChoiceXML.append(wrongChoice);
		return "<SubQuestion>"+getText()+getType()+getMark()+correctChoiceXML+wrongChoiceXML+"</SubQuestion>";
	}
	
	public int getChoicesCount(){
		return correctChoices.size() + wrongChoices.size();
	}
}
